package com.ttai.presenter.activity;

import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import android.widget.Toast;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.ttai.model.dao.DBHelper;
import com.ttai.model.net.ResponseInfo;
import com.ttai.model.net.TipAcountBean;
import com.ttai.presenter.base.BasePresenter;
import com.ttai.ui.activity.EnterPage;
import com.ttai.ui.activity.VerifyLogin;
import com.ttai.ui.activity.VerifyMiYao;

import retrofit2.Call;

public class InsertTipAcountPresenter extends BasePresenter {
    EnterPage enterPage;
    VerifyLogin verifyLogin;
    VerifyMiYao verifyMiYao;
    private String tip;


    @Override
    protected void showError(String message) {
        Toast.makeText(enterPage, message, Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void parseJson(JsonObject json) {
        Log.i("123", "parseJson: 查询tip成功");
        Gson gson = new Gson();
        TipAcountBean tipAcountBean = gson.fromJson(json, TipAcountBean.class);
        String phone = tipAcountBean.getTaiAccount();
        tip = tipAcountBean.getTip();
        System.out.println("tip :"+tip);
//            DBHelper dbHelper = DBHelper.getInstance(enterPage);
//            SQLiteDatabase db1=dbHelper.getWritableDatabase();
//            ContentValues value=new ContentValues();
//            value.put("phone",phone);
//            value.put("tip",tip);
//            db1.insert("tipacount",null,value);
//            value.clear();
    }

    public void storeTipAcount(String token) {
        Call<ResponseInfo> tipAcountInfo = responseInfoApi.restoreTipAcount(token);
        tipAcountInfo.enqueue(new CallBackAdapter());
    }

    public String getTip() {
        return tip;
    }
}
